opt_level: uint,
debug: bool,
test: bool,
+ doc: bool,
dest: Option<String>,
plugin: bool,
}
impl Profile {
+ fn default() -> Profile {
+ Profile {
+ env: String::new(),
+ opt_level: 0,
+ debug: false,
+ test: false,
+ doc: false,
+ dest: None,
+ plugin: false,
+ }
+ }
+
pub fn default_dev() -> Profile {
Profile {
env: "compile".to_string(), // run in the default environment only
test: false, // whether or not to pass --test
dest: None,
plugin: false,
+ doc: false,
}
}
pub fn default_test() -> Profile {
Profile {
- env: "test".to_string(), // run in the default environment only
- opt_level: 0,
+ env: "test".to_string(),
debug: true,
- test: true, // whether or not to pass --test
+ test: true,
dest: Some("test".to_string()),
- plugin: false,
+ .. Profile::default()
}
}
pub fn default_bench() -> Profile {
Profile {
- env: "bench".to_string(), // run in the default environment only
+ env: "bench".to_string(),
opt_level: 3,
- debug: false,
- test: true, // whether or not to pass --test
+ test: true,
dest: Some("bench".to_string()),
- plugin: false,
+ .. Profile::default()
}
}
pub fn default_release() -> Profile {
Profile {
- env: "release".to_string(), // run in the default environment only
+ env: "release".to_string(),
opt_level: 3,
- debug: false,
- test: false, // whether or not to pass --test
dest: Some("release".to_string()),
- plugin: false,
+ .. Profile::default()
}
}
pub fn default_doc() -> Profile {
Profile {
env: "doc".to_string(),
- opt_level: 0,
- debug: false,
- test: false,
dest: Some("doc-build".to_string()),
- plugin: false,
+ doc: true,
+ .. Profile::default()
}
}
}
pub fn is_doc(&self) -> bool {
- self.env.as_slice() == "doc"
+ self.doc
}
pub fn is_test(&self) -> bool {
self
}
+ pub fn doc(mut self, doc: bool) -> Profile {
+ self.doc = doc;
+ self
+ }
+
pub fn plugin(mut self, plugin: bool) -> Profile {
self.plugin = plugin;
self
// doc-all == document everything, so look for doc targets and
// compile targets in dependencies
"doc-all" => target.get_profile().is_compile() ||
- target.get_profile().is_doc(),
+ (target.get_profile().get_env() == "doc" &&
+ target.get_profile().is_doc()),
_ => target.get_profile().get_env() == self.env,
}
}
let kind = KindTarget;
let pkg_root = package.get_root();
let cx_root = cx.layout(kind).proxy().dest().dir_path().join("doc");
- let rustdoc = util::process("rustdoc").cwd(pkg_root.clone());
+ let rustdoc = process("rustdoc", package, cx).cwd(pkg_root.clone());
let rustdoc = rustdoc.arg(target.get_src_path())
.arg("-o").arg(cx_root)
.arg("--crate-name").arg(target.get_name());
-use support::{project, execs};
+use support::{project, execs, cargo_dir};
use hamcrest::assert_that;
fn setup() {
version = "0.0.1"
authors = []
+ [[lib]]
+ name = "foo_lib"
+
[dependencies.bar]
path = "../bar"
"#)
.file("src/main.rs", r#"
#![feature(phase)]
#[phase(plugin)] extern crate bar;
+ extern crate foo_lib;
- fn main() {}
+ fn main() { foo_lib::foo(); }
+ "#)
+ .file("src/foo_lib.rs", r#"
+ #![feature(phase)]
+ #[phase(plugin)] extern crate bar;
+
+ pub fn foo() {}
"#);
let bar = project("bar")
.file("Cargo.toml", r#"
assert_that(foo.cargo_process("cargo-build"),
execs().with_status(0));
+ assert_that(foo.process(cargo_dir().join("cargo-doc")),
+ execs().with_status(0));
})